{"ast":null,"code":"/**\n * This function create an object from keys, value and then assign to target\n *\n * @param {Object} obj : the target object to be assigned\n * @param {string[]} keys\n * @param {string | number} value\n *\n * @example\n * const source = {}\n * assignNestedKeys(source, ['palette', 'primary'], 'var(--palette-primary)')\n * console.log(source) // { palette: { primary: 'var(--palette-primary)' } }\n *\n * @example\n * const source = { palette: { primary: 'var(--palette-primary)' } }\n * assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')\n * console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }\n */\nexport const assignNestedKeys = function (obj, keys, value) {\n  let arrayKeys = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];\n  let temp = obj;\n  keys.forEach((k, index) => {\n    if (index === keys.length - 1) {\n      if (Array.isArray(temp)) {\n        temp[Number(k)] = value;\n      } else if (temp && typeof temp === 'object') {\n        temp[k] = value;\n      }\n    } else if (temp && typeof temp === 'object') {\n      if (!temp[k]) {\n        temp[k] = arrayKeys.includes(k) ? [] : {};\n      }\n      temp = temp[k];\n    }\n  });\n};\n/**\n *\n * @param {Object} obj : source object\n * @param {Function} callback : a function that will be called when\n *                   - the deepest key in source object is reached\n *                   - the value of the deepest key is NOT `undefined` | `null`\n *\n * @example\n * walkObjectDeep({ palette: { primary: { main: '#000000' } } }, console.log)\n * // ['palette', 'primary', 'main'] '#000000'\n */\n\nexport const walkObjectDeep = (obj, callback, shouldSkipPaths) => {\n  function recurse(object) {\n    let parentKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n    let arrayKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];\n    Object.entries(object).forEach(_ref => {\n      let [key, value] = _ref;\n      if (!shouldSkipPaths || shouldSkipPaths && !shouldSkipPaths([...parentKeys, key])) {\n        if (value !== undefined && value !== null) {\n          if (typeof value === 'object' && Object.keys(value).length > 0) {\n            recurse(value, [...parentKeys, key], Array.isArray(value) ? [...arrayKeys, key] : arrayKeys);\n          } else {\n            callback([...parentKeys, key], value, arrayKeys);\n          }\n        }\n      }\n    });\n  }\n  recurse(obj);\n};\nconst getCssValue = (keys, value) => {\n  if (typeof value === 'number') {\n    if (['lineHeight', 'fontWeight', 'opacity', 'zIndex'].some(prop => keys.includes(prop))) {\n      // CSS property that are unitless\n      return value;\n    }\n    const lastKey = keys[keys.length - 1];\n    if (lastKey.toLowerCase().indexOf('opacity') >= 0) {\n      // opacity values are unitless\n      return value;\n    }\n    return `${value}px`;\n  }\n  return value;\n};\n/**\n * a function that parse theme and return { css, vars }\n *\n * @param {Object} theme\n * @param {{\n *  prefix?: string,\n *  shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean\n * }} options.\n *  `prefix`: The prefix of the generated CSS variables. This function does not change the value.\n *\n * @returns {{ css: Object, vars: Object, parsedTheme: typeof theme }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme), and `parsedTheme` is the cloned version of theme.\n *\n * @example\n * const { css, vars, parsedTheme } = parser({\n *   fontSize: 12,\n *   lineHeight: 1.2,\n *   palette: { primary: { 500: 'var(--color)' } }\n * }, { prefix: 'foo' })\n *\n * console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }\n * console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }\n * console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }\n */\n\nexport default function cssVarsParser(theme, options) {\n  const {\n    prefix,\n    shouldSkipGeneratingVar\n  } = options || {};\n  const css = {};\n  const vars = {};\n  const parsedTheme = {};\n  walkObjectDeep(theme, (keys, value, arrayKeys) => {\n    if (typeof value === 'string' || typeof value === 'number') {\n      if (!shouldSkipGeneratingVar || !shouldSkipGeneratingVar(keys, value)) {\n        // only create css & var if `shouldSkipGeneratingVar` return false\n        const cssVar = `--${prefix ? `${prefix}-` : ''}${keys.join('-')}`;\n        Object.assign(css, {\n          [cssVar]: getCssValue(keys, value)\n        });\n        assignNestedKeys(vars, keys, `var(${cssVar})`, arrayKeys);\n      }\n    }\n    assignNestedKeys(parsedTheme, keys, value, arrayKeys);\n  }, keys => keys[0] === 'vars' // skip 'vars/*' paths\n  );\n\n  return {\n    css,\n    vars,\n    parsedTheme\n  };\n}","map":{"version":3,"names":["assignNestedKeys","obj","keys","value","arrayKeys","temp","forEach","k","index","length","Array","isArray","Number","includes","walkObjectDeep","callback","shouldSkipPaths","recurse","object","parentKeys","Object","entries","key","undefined","getCssValue","some","prop","lastKey","toLowerCase","indexOf","cssVarsParser","theme","options","prefix","shouldSkipGeneratingVar","css","vars","parsedTheme","cssVar","join","assign"],"sources":["/data/messenger.client/node_modules/@mui/system/esm/cssVars/cssVarsParser.js"],"sourcesContent":["/**\n * This function create an object from keys, value and then assign to target\n *\n * @param {Object} obj : the target object to be assigned\n * @param {string[]} keys\n * @param {string | number} value\n *\n * @example\n * const source = {}\n * assignNestedKeys(source, ['palette', 'primary'], 'var(--palette-primary)')\n * console.log(source) // { palette: { primary: 'var(--palette-primary)' } }\n *\n * @example\n * const source = { palette: { primary: 'var(--palette-primary)' } }\n * assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')\n * console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }\n */\nexport const assignNestedKeys = (obj, keys, value, arrayKeys = []) => {\n  let temp = obj;\n  keys.forEach((k, index) => {\n    if (index === keys.length - 1) {\n      if (Array.isArray(temp)) {\n        temp[Number(k)] = value;\n      } else if (temp && typeof temp === 'object') {\n        temp[k] = value;\n      }\n    } else if (temp && typeof temp === 'object') {\n      if (!temp[k]) {\n        temp[k] = arrayKeys.includes(k) ? [] : {};\n      }\n\n      temp = temp[k];\n    }\n  });\n};\n/**\n *\n * @param {Object} obj : source object\n * @param {Function} callback : a function that will be called when\n *                   - the deepest key in source object is reached\n *                   - the value of the deepest key is NOT `undefined` | `null`\n *\n * @example\n * walkObjectDeep({ palette: { primary: { main: '#000000' } } }, console.log)\n * // ['palette', 'primary', 'main'] '#000000'\n */\n\nexport const walkObjectDeep = (obj, callback, shouldSkipPaths) => {\n  function recurse(object, parentKeys = [], arrayKeys = []) {\n    Object.entries(object).forEach(([key, value]) => {\n      if (!shouldSkipPaths || shouldSkipPaths && !shouldSkipPaths([...parentKeys, key])) {\n        if (value !== undefined && value !== null) {\n          if (typeof value === 'object' && Object.keys(value).length > 0) {\n            recurse(value, [...parentKeys, key], Array.isArray(value) ? [...arrayKeys, key] : arrayKeys);\n          } else {\n            callback([...parentKeys, key], value, arrayKeys);\n          }\n        }\n      }\n    });\n  }\n\n  recurse(obj);\n};\n\nconst getCssValue = (keys, value) => {\n  if (typeof value === 'number') {\n    if (['lineHeight', 'fontWeight', 'opacity', 'zIndex'].some(prop => keys.includes(prop))) {\n      // CSS property that are unitless\n      return value;\n    }\n\n    const lastKey = keys[keys.length - 1];\n\n    if (lastKey.toLowerCase().indexOf('opacity') >= 0) {\n      // opacity values are unitless\n      return value;\n    }\n\n    return `${value}px`;\n  }\n\n  return value;\n};\n/**\n * a function that parse theme and return { css, vars }\n *\n * @param {Object} theme\n * @param {{\n *  prefix?: string,\n *  shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean\n * }} options.\n *  `prefix`: The prefix of the generated CSS variables. This function does not change the value.\n *\n * @returns {{ css: Object, vars: Object, parsedTheme: typeof theme }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme), and `parsedTheme` is the cloned version of theme.\n *\n * @example\n * const { css, vars, parsedTheme } = parser({\n *   fontSize: 12,\n *   lineHeight: 1.2,\n *   palette: { primary: { 500: 'var(--color)' } }\n * }, { prefix: 'foo' })\n *\n * console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }\n * console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }\n * console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }\n */\n\n\nexport default function cssVarsParser(theme, options) {\n  const {\n    prefix,\n    shouldSkipGeneratingVar\n  } = options || {};\n  const css = {};\n  const vars = {};\n  const parsedTheme = {};\n  walkObjectDeep(theme, (keys, value, arrayKeys) => {\n    if (typeof value === 'string' || typeof value === 'number') {\n      if (!shouldSkipGeneratingVar || !shouldSkipGeneratingVar(keys, value)) {\n        // only create css & var if `shouldSkipGeneratingVar` return false\n        const cssVar = `--${prefix ? `${prefix}-` : ''}${keys.join('-')}`;\n        Object.assign(css, {\n          [cssVar]: getCssValue(keys, value)\n        });\n        assignNestedKeys(vars, keys, `var(${cssVar})`, arrayKeys);\n      }\n    }\n\n    assignNestedKeys(parsedTheme, keys, value, arrayKeys);\n  }, keys => keys[0] === 'vars' // skip 'vars/*' paths\n  );\n  return {\n    css,\n    vars,\n    parsedTheme\n  };\n}"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,gBAAgB,GAAG,UAACC,GAAG,EAAEC,IAAI,EAAEC,KAAK,EAAqB;EAAA,IAAnBC,SAAS,uEAAG,EAAE;EAC/D,IAAIC,IAAI,GAAGJ,GAAG;EACdC,IAAI,CAACI,OAAO,CAAC,CAACC,CAAC,EAAEC,KAAK,KAAK;IACzB,IAAIA,KAAK,KAAKN,IAAI,CAACO,MAAM,GAAG,CAAC,EAAE;MAC7B,IAAIC,KAAK,CAACC,OAAO,CAACN,IAAI,CAAC,EAAE;QACvBA,IAAI,CAACO,MAAM,CAACL,CAAC,CAAC,CAAC,GAAGJ,KAAK;MACzB,CAAC,MAAM,IAAIE,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;QAC3CA,IAAI,CAACE,CAAC,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